<?php 
date_default_timezone_set("Australia/Melbourne");
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
/* <![CDATA[ */

table, td
{
    border-color: #666;
    border-style: solid;
}
table, th
{
    border-color: #666;
    border-style: solid;
}

table
{
    border-width: 0 0 1px 1px;
    border-spacing: 0;
    border-collapse: collapse;
}

td
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}
th
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}

/* ]]> */
</style>

<style type="text/css">
.graph {
background-color: #C8C8C8;
border: solid 1px black;
}
.graph td {
font-family: verdana, arial, sans serif;
}
.graph thead th {
border-bottom: double 3px black;
font-family: verdana, arial, sans serif;
padding: 1em;
}
.graph tfoot td {
border-top: solid 1px #999999;
font-size: x-small;
text-align: center;
padding: 0.5em;
color: #666666;
}
.bar {
background-color: white;
text-align: right;
border-left: solid 1px black;
padding-right: 0.5em;
width: 400px;
}
.bar div {
border-top: solid 2px #0077DD;
background-color: #004080;
border-bottom: solid 2px #002266;
text-align: right;
color: white;
float: left;
padding-top: 0;
height: 1em;
}
body {
background-color: white;
}

table, td
{
    border-color: #666;
    border-style: solid;
}
table, th
{
    border-color: #666;
    border-style: solid;
}

table
{
    border-width: 0 0 1px 1px;
    border-spacing: 0;
    border-collapse: collapse;
}

td
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}
th
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}

/* ]]> */
</style>
</head>
<body style="font-family:Arial, Helvetica, sans-serif;">


<h1>Weekly Shops Progress Summary</h1>

** The "*" means we successfully gathered sales data from the apos, "-" means no data gathered.  <br />


<table width="1000" border="0" cellspacing="1" cellpadding="5">
  <tr>
    <th scope="col">Shop</th>
    <th scope="col">Target</th>
    <th scope="col">Progress %</th>
    <th scope="col"> Total
<br />
 <span style="font-size:10px;">Monday - <?php echo date("l",strtotime(Model_DatetimeHelper::dateYesterday()));?> </span>    
    </th> 
    <th scope="col">Remain<br />
 <span style="font-size:10px;"><?php echo date("l")?> - Sunday </span>
    </th>
    <th scope="col">Remain<br />
    Daily Target</th>
    <td align="center" valign="middle" scope="col" >Total <br />
    Days**</td>        
    <td align="center" valign="middle"  scope="col" > <?php echo date("l",strtotime(Model_DatetimeHelper::dateYesterday()));?><br /><span style="font-size:10px;">(Yesterday)</span></td>
    <td align="center" valign="middle"  scope="col" ><?php echo date("l",strtotime(Model_DatetimeHelper::dateYesterday()));?><span style="font-size:10px;"><br />
    (of Last Week)</span></td>
    <td align="center" valign="middle"  scope="col" >Target2</td>
    <td align="center" valign="middle"  scope="col" >Target3</td>
  </tr>
  <?php 
  $thisWeekTotal = 0;
  $lastWeekTotal = 0;

  foreach($this->arrRes as $k => $v){
	  $thisWeekTotal += $v["week_total"];
	  $lastWeekTotal += $v["last_week_sofar"];
	  
	  ?>
  <tr 
  <?php
  if($v["color"]){
	  echo 'style="background:#CCC;"';
	  }
  ?> >
    <td><?php echo $v["shop"]?></td>
    <td>$ <?php echo $v["target"]?></td>
    <td><?php echo $v["percent"]?> %</td>
    <td>$ <?php echo $v["week_total"]?></td>
    <td>$ <?php echo $v["remain"]?></td>
    <td>$ <?php echo $v["daily_target"]?></td>
    <td>
	<?php
		foreach($v["week_days"] as $days){
			echo ($days==0)?"-":"*";
			}
    
	?></td>   
    <td>$ <?php echo $v["yesterday"]?></td>
    <td>$ <?php echo $v["2days"]?> </td>
    <td>$ <?php echo $v["target2"]?></td>
    <td>$ <?php echo $v["target3"]?></td>
  </tr>
  <?php }?>
  <tr>
  <td colspan="8" align="right"> This Week Total :$<?php echo $thisWeekTotal?>   | Last Week Total :$<?php echo $lastWeekTotal?>  </td>
  <td colspan = "3">&nbsp;</td>
  </tr>
</table><br />
If you can not see the progress bar chart below ,please let me know<br />
<br />

<table width="700" cellspacing="6" cellpadding="0" class="graph" style="background-color: #FFFFFF;
border: solid 1px black;">
      <thead>
        <tr><th colspan="3" style="border-bottom: double 3px black;
font-family: verdana, arial, sans serif;
padding: 1em;">Your Shops Progress</th></tr>
      </thead>
      <tbody>
    <?php foreach($this->arrRes as $k => $v){?>    
        <tr>
          <td width="150"><?php echo $v["shop"]?>($ <?php echo $v["target"]?>)</td><td width="400"  style="background-color: white;
text-align: right;
border-left: solid 1px black;
padding-right: 0.5em;
width: 400px;"><div style = "
<?php
if($v["week_total"] >= $v["last_week_sofar"]){
	echo "background-color: #006800;";
	}
else{
	echo "background-color:#680000;";
	}	
?>
 color:white; float:left ; border-bottom: solid 2px #002266; border-top: solid 2px #0077DD; width: <?php echo $v["percent"]?>%;" ><?php echo $v["percent"]?>%</div><div style="float:left; font-size:12px; font-style:italic; margin-top:2px;"> $<?php echo $v["week_total"]?></div>$ <?php echo $v["remain"]?>
</td><td>$ <?php echo $v["daily_target"]?><span style="font-size:8px; font-style:italic;">/preday remain</span></td>
        </tr>
        <tr>
          <td width="150" align="right"><span style="font-size:8px; font-style:italic;"><?php echo $v["shop"]?> Last Week</span></td>
          <td  style="background-color: white;
text-align: right;
border-left: solid 1px black;
padding-right: 0.5em;
width: 400px;">
<div style = "background-color:#CCC; color:white; float:left ; width: <?php echo $v["last_week_precent"]?>%;" >&nbsp;</div><div style="float:left; font-size:12px; font-style:italic; margin-top:2px;"> $<?php echo $v["last_week_sofar"]?></div></td>
          <td> $<?php echo $v["last_week_total"]?><span style="font-size:8px; font-style:italic;">Total</span></td>
        </tr>
   <?php }?>

      </tbody>
      <tfoot>
        <tr><td colspan="3" style="border-top: solid 1px #999999;
font-size: x-small;
text-align: center;
padding: 0.5em;
color: #666666;">Sales Data Gathered To :<?php echo Model_DatetimeHelper::dateYesterday();?></td></tr>
      </tfoot>
    </table>
<h1>Attendance Problems Yesterday</h1>
The Following Problems will show in your &quot;Roster Listing Problems&quot; ONLY AFTER you confirmed your roster.<br />
Please Make Sure Create Case Within 14 Days After The Incidence Occur. Please Check The Related Company Policy Here.<br />
<br />
<table width="800" border="1" cellspacing="0" cellpadding="15">
  <tr>
    <td align="center">Staff</td>
    <td align="center">Date</td>
    <td align="center">Shop</td>
    <td align="center">On-Duty</td>
    <td align="center">Off-Duty</td>
  </tr>
  <?php 
  foreach($this->arrMiss as $v){
  ?>
  <tr>
    <td><?php 
	$st = new Model_DbTable_Roster_Stafflogindetail();
	$stLine = $st->getDetail($v[0]);
	$name = Model_EncryptHelper::getSslPassword($stLine['n']);
	
	$nickName = $stLine['ni'];
	if(trim($nickName)==""){
		$nickName = $name;
		}
	echo "[{$v[0]}] {$nickName} <span></span>"; 
	?></td>
    <td><?php echo $v[1] ?></td>
    <td><?php echo $v[2] ?></td>
    <td><?php echo $v[3] ?></td>
    <td><?php echo $v[4] ?></td>
  </tr>
  <?php }?>
  
</table>
<br />
<br />
</body>
</html>
<?php
$mailbody = ob_get_contents();
if($this->ifemail == "yes"){
$mail = new Model_Emailshandler();

$mail->sendNormalEmail($this->email,"Daily Shop Sales Progress Summary Version 1.0", $mailbody);
if($this->email == "phonecollection.au@gmail.com"){
$mail->sendNormalEmail("admin@phonecollection.com.au","Daily Shop Sales Progress Summary Version 1.0", $mailbody);	
$mail->sendNormalEmail("simon.seop@phonecollection.com.au","Daily Shop Sales Progress Summary Version 1.0", $mailbody);	
$mail->sendNormalEmail("eco3@phonecollection.com.au","Daily Shop Sales Progress Summary Version 1.0", $mailbody);

	}



}
?>